home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
ddj1291.zip
/
STAT.ZIP
/
SOURCE.ZIP
/
PAES1800.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-05-10
|
26KB
|
774 lines
/* File: paes1800.c
**
** Copyright 1990
** Fred Motteler and Applied Microsystems Corporation
** All Rights Reserved
**
** Description: Utility functions used by the ES 1800 version of the
** statistical performance analysis package.
*/
#include <stdio.h>
#include <dos.h>
#include <fcntl.h>
#include <string.h>
#include <comm.h> /* This is a Lattice specific library */
#include <time.h> /* For machine independent timeouts */
#include "padef.h"
/*
** Function: int main( argcN, argvAS )
**
** Description: ES 1800 based statistical performance analysis program.
**
** Command line arguments:
**
** paes1800 prog.map prog.cfg samptime cycles
**
** Where: prog.map memory map for program
** prog.cfg memory map configuration
** samptime total sampling time (sec)
** cycles bus cycles between samples
*/
int
main( argcN, argvAS )
int argcN;
char *argvAS[];
{
int errorN; /* Error code */
COMPORT comN; /* Handle to comport to use */
char comportAB[8]; /* String for comport ID, "1" or "2" */
int comportN; /* Comport number, 1 or 2 */
char baudrateAB[12]; /* String for baudrate, "9600", "19200", etc */
long baudrateL; /* Baudrate value, 9600, 19200, etc... */
char estypeAB[12]; /* Emulator type, "68020S", "68020U", etc... */
char runstopAB[16]; /* Emulator run/stop mode "boot_stop", etc.. */
char listAB[80]; /* Optional results listing file path/name */
char pagelinesAB[8]; /* String for number of lines/page */
int estypeN; /* Emulator type code */
int esoperationN; /* Emulator operation code */
int samptimeN; /* Sampling duration in seconds */
unsigned int cyclesN; /* Number of buss cycles between samples */
int processedN; /* Number of map globals processed */
FILE *mapFP; /* Map file to read */
FILE *formatFP; /* File with map file format information */
int pagelinesN; /* Number of lines on output page, 0 if
* continuous, -1 if no display output, else
* n if n lines per page. */
FILE *listFP; /* Results output file */
printf("paes1800 - Statistical performance analysis tool for the ES 1800\n");
printf("Version %s\n", PA_VERSION);
printf("Copyright (C) 1990 Fred Motteler and Applied Microsystems Corporation\n");
if (argcN < 5)
{
printf("Usage: paes1800 prog.map prog.cfg samptime cycles\n");
printf(" Where: prog.map memory map for program\n");
printf(" prog.cfg configuration file\n");
printf(" samptime total sampling time (sec)\n");
printf(" cycles bus cycles between samples\n");
exit(-100);
}
/* First open up the configuration file. */
if ((formatFP = fopen(argvAS[2], "r")) == (FILE *) NULL)
{
pa_error(PA_NO_CFG_E);
exit(PA_NO_CFG_E);
}
/* Read in serial port, emulator, display lines, and optional output
* file configuration data from the configuration file. */
if (((errorN = paconfig(formatFP, PA_COMPORT, comportAB)) != 0) ||
((errorN = paconfig(formatFP, PA_BAUDRATE, baudrateAB)) != 0) ||
((errorN = paconfig(formatFP, PA_ESTYPE, estypeAB)) != 0) ||
((errorN = paconfig(formatFP, PA_RUNSTOP, runstopAB)) != 0) ||
((errorN = paconfig(formatFP, PA_PAGELINES, pagelinesAB)) != 0) ||
((errorN = paconfig(formatFP, PA_LISTFILE, listAB)) != 0))
{
pa_error(errorN);
fclose(formatFP);
exit(errorN);
}
if (((sscanf(comportAB, "%d", &comportN)) != 1) ||
((sscanf(pagelinesAB, "%d", &pagelinesN)) != 1) ||
((sscanf(baudrateAB, "%ld", &baudrateL)) != 1))
{
pa_error(PA_BAD_ARG_E);
fclose(formatFP);
exit(PA_BAD_ARG_E);
}
/* Open a listing file */
if (listAB[0] == '\0')
listFP = (FILE *) NULL;
else if ((listFP = fopen(listAB, "w")) == (FILE *) NULL)
{
pa_error(PA_NO_LST_E);
fclose(formatFP);
exit(PA_NO_LST_E);
}
/* Open a serial port */
comN = ComOpen("COM", comportN, baudrateL, 8, NO_PARITY, 1, 1024, 1, NULL);
/* Determine the "basic" emulator type */
if (strcmp(estypeAB, "68020S") == 0)
estypeN = PA_020S; /* 68020 (supervisor prog. fetch) */
else if (strcmp(estypeAB, "68020U") == 0)
estypeN = PA_020U; /* 68020 (user prog. fetch) */
else if (strcmp(estypeAB, "68000S") == 0)
estypeN = PA_000S; /* 68000 (supervisor prog. fetch) */
else if (strcmp(estypeAB, "68000U") == 0)
estypeN = PA_000U; /* 68000 (user prog. fetch) */
else if (strcmp(estypeAB, "80X86") == 0)
estypeN = PA_80X86; /* 80X86 */
else if (strcmp(estypeAB, "Z800X") == 0)
estypeN = PA_Z8K; /* Z800X */
else
{
pa_error(PA_NOT_IMPL_E);
fclose(formatFP);
ComClose(comN);
return(PA_NOT_IMPL_E);
}
/* Determine the emulator operation mode */
if (strcmp(runstopAB, "boot_stop") == 0)
esoperationN = PA_RST_RBV_STP; /* Use ESL "RST", "RBV", "STP" */
else if (strcmp(runstopAB, "run_stop") == 0)
esoperationN = PA_RBK_STP; /* Use ESL "RBK", "STP */
else if (strcmp(runstopAB, "run_run") == 0)
esoperationN = PA_RBK_RUN; /* Use ESL "RBK", "RUN */
else
{
pa_error(PA_NOT_IMPL_E);
fclose(formatFP);
ComClose(comN);
return(PA_NOT_IMPL_E);
}
/* Determine the total sample time, and the number of cycles between
* samples. */
if (((sscanf(argvAS[3], "%d", &samptimeN)) != 1) ||
((sscanf(argvAS[4], "%d", &cyclesN)) != 1))
{
pa_error(PA_BAD_ARG_E);
fclose(formatFP);
ComClose(comN);
return(PA_BAD_ARG_E);
}
/* Run the program and collect samples. */
if ((errorN = pa_essample(comN, estypeN, esoperationN, PA_SAMPLE,
samptimeN, cyclesN)) != 0)
{
pa_error(errorN);
fclose(formatFP);
ComClose(comN);
exit(errorN);
}
/* Read the program's memory map and create "bins" for the program
* counter samples. */
if ((mapFP = fopen(argvAS[1], "r")) == (FILE *) NULL)
{
pa_error(PA_NO_MAP_E);
fclose(formatFP);
ComClose(comN);
exit(PA_NO_MAP_E);
}
if ((errorN = pardmap(mapFP, formatFP, 0L, &processedN)) != 0)
{
pa_error(errorN);
fclose(formatFP);
fclose(mapFP);
ComClose(comN);
exit(errorN);
}
/* Process the samples and sort the bins according to the PC hits in
* each bin. */
printf("Processing samples\n");
if ((errorN = pa_bstuff(PA_SAMPLE, patableAHP, &processedN)) != 0)
{
pa_error(errorN);
fclose(formatFP);
fclose(mapFP);
ComClose(comN);
exit(errorN);
}
/* Display the results and/or dump them to a file. */
padisply(patableAHP, processedN, pagelinesN, listFP);
fclose(formatFP);
fclose(mapFP);
ComClose(comN);
exit(0);
}
/*
** Function: int pa_essend(COMPORT comN, char *stringS)
**
** Description: This is a simple function that sends a string to the
** emulator and waits for a prompt responce. "comN" is
** a port handle, returned from the Lattice "ComOpen()"
** library function.
**
** If the send is successful, then a 0 is returned. Otherwise
** an error code is returned.
*/
int
pa_essend(comN, stringS)
COMPORT comN; /* com port handle */
char *stringS; /* String to output */
{
time_t t; /* Time value for timeout delay */
int int_charN; /* Serial port character */
t = time(NULL); /* Get starting time. */
/* Send the string and wait until either a prompt is returned, or a
* time out occurs. */
ComPuts(comN, stringS);
while((int_charN = ComGetc(comN)) != ((int) '>'))
{
if ((pa_debugN & PA_SER_IN) != 0)
putchar(int_charN);
if ((time(NULL) - t) > PA_TIMEOUT)
return(PA_ES_NORESP_E);
}
return(0);
}
/*
** Function: int pa_estup(COMPORT comN, char *tupfileS)
**
** Description: This is a simple function that sends the "TUP 0 TO #2045"
** command to a ES 1800 68020 emulator. The address values are
** determined from the response, and are written to the binary
** file named by tupfileP.
**
** If the TUP command is successful, then a 0 is returned.
** Otherwise an error code is returned.
*/
int
pa_estup(comN, tupfileS)
COMPORT comN; /* com port handle */
char *tupfileS; /* File to write TUP data to */
{
time_t t; /* Time value for timeout delay */
int int_charN; /* Serial port character */
int handleN; /* File handle for tup data */
unsigned long addressL; /* Address from tup command */
int digit_countN; /* Digit count in tup response line */
t = time(NULL); /* Get starting time */
if ((handleN = open(tupfileS, (O_CREAT | O_WRONLY | O_RAW), 0)) == (-1))
return(PA_NO_TUP_FILE_E);
/* Send the TUP command. */
ComPuts(comN, "TUP 0 TO #2045\r");
/* Wait for the first colon character from the TUP command */
while((int_charN = ComGetc(comN)) != ((int) ':'))
{
if ((pa_debugN & PA_SER_IN) != 0)
putchar(int_charN);
if ((time(NULL) - t) > PA_TIMEOUT)
{
close(handleN);
return(PA_ES_NORESP_E);
}
}
/* We have the first colon, continue reading until we get an ESL
* prompt. As we read each trace buffer record (one bus cycle per
* record), the address value is extraced. The result is then written
* to a binary file. */
addressL = 0L;
digit_countN = 0;
while((int_charN = ComGetc(comN)) != ((int) '>'))
{
/* Check if the input queue is temporarily empty. If so, then try
* again... */
if (int_charN == (-1))
continue;
if ((pa_debugN & PA_SER_IN) != 0)
putchar(int_charN);
if (int_charN == ':')
{
/* Write out the address value. The byte order of the value
* written out is host dependent. Thus it must be read in the
* same way. */
if (write(handleN, ((char *) &addressL), sizeof(addressL)) !=
sizeof(addressL))
{
close(handleN);
return(PA_NO_TUP_WR_E);
}
/* Re-initialize address and digit count values for next
* record. */
addressL = 0L;
digit_countN = 0;
}
else if (isxdigit(int_charN))
{
/* Collect the proper address digits */
if (digit_countN++ < 6)
{
/* Hex digits 0 through 5 are the low 24 bits of address. */
addressL <<= 4;
addressL += pa_hextobin(int_charN);
}
else if (digit_countN == 11)
{
/* Hex digits 10 and 11 are the high 8 bits of the address.
* Note that the digit count has already been incremented,
* so the comparison values are one greater than the digit
* values. First read the ms digit. */
addressL += (((unsigned long) pa_hextobin(int_charN)) << 28);
}
else if (digit_countN == 12)
{
/* Then read the ls digit. */
addressL += (((unsigned long) pa_hextobin(int_charN)) << 24);
}
}
}
/* Write out the last address value. The byte order of the value written
* out is host dependent. Thus it must be read in the same way. */
if (write(handleN, ((char *) &addressL), sizeof(addressL)) !=
sizeof(addressL))
return(PA_NO_TUP_WR_E);
close(handleN);
return(0);
}
/*
** Function: int pa_esdrt(COMPORT comN, char *drtfileS)
**
** Description: This is a simple function that sends the "DRT 0 TO #2045"
** command to a ES 1800 emulator. The address values are
** determined from the response, and are written to the binary
** file named by drtfileP.
**
** The basic DRT format looked for is:
**
** #line_count addresss ...other stuff...
**
** Lines with
**
** #line_count BREAK
**
** are ignored.
**
** If the DRT command is successful, then a 0 is returned.
** Otherwise an error code is returned.
*/
int
pa_esdrt(comN, drtfileS)
COMPORT comN; /* com port handle */
char *drtfileS; /* File to write DRT data to */
{
time_t t; /* Time value for timeout delay */
int int_charN; /* Serial port character */
int handleN; /* File handle for drt data */
unsigned long addressL; /* Address from drt command */
int digit_countN; /* Digit count in drt response line */
char responseAB[256]; /* DRT resp line - may be several lines */
int line_countN; /* Line count value of DRT response line */
int i; /* Index to count '#' characters */
t = time(NULL); /* Get starting time */
line_countN = 2045; /* Initialize to maximum trace line count */
if ((handleN = open(drtfileS, (O_CREAT | O_WRONLY | O_RAW), 0)) == (-1))
return(PA_NO_DRT_FILE_E);
/* Send the DRT command. */
ComPuts(comN, "DRT 0 TO #2045\r");
/* Wait for the first two '#' characters from the DRT command response.
* The first is in the DRT command, the second is the first line of
* trace memory. */
for (i = 0; i < 2; i++)
{
while((int_charN = ComGetc(comN)) != ((int) '#'))
{
if ((pa_debugN & PA_SER_IN) != 0)
putchar(int_charN);
if ((time(NULL) - t) > PA_TIMEOUT)
{
close(handleN);
return(PA_ES_NORESP_E);
}
}
}
/* We have the first '#' character, continue reading until the line
* count value of 1 is reached. */
digit_countN = 0; /* Start "lines" just after '#' character */
while (line_countN != 1)
{
/* Read in a character. If the input queue is empty, then continue
* trying. */
while((int_charN = ComGetc(comN)) == (-1));
if ((pa_debugN & PA_SER_IN) != 0)
putchar(int_charN);
if (int_charN != '#')
{
/* Collect the characters of the line */
responseAB[digit_countN] = int_charN;
digit_countN++;
if ((digit_countN < 0) || (digit_countN > 255))
{
close(handleN);
return(PA_DCOUNT_OUT_E);
}
}
else
{
/* We have a '#' character, process the input line.
* First Nul terminate the line. */
responseAB[digit_countN] = '\0';
/* Check if the line contains "BREAK", if so, then skip it. */
if (pa_strsrch(responseAB, "BREAK") == 0)
{
/* Line does not contain a "BREAK", read in its line number
* and the address value. */
if (sscanf(responseAB, "%d %lx", &line_countN, &addressL) != 2)
{
close(handleN);
return(PA_BAD_DRT_RD_E);
}
if ((line_countN < 0) || (line_countN > 2045))
{
close(handleN);
return(PA_LCOUNT_OUT_E);
}
/* Write out the address value. The byte order of the value
* written out is host dependent. Thus it must be read in the
* same way. */
if (write(handleN, ((char *) &addressL), sizeof(addressL)) !=
sizeof(addressL))
{
close(handleN);
return(PA_NO_DRT_WR_E);
}
}
/* Re-initialize digit count values for next record. */
digit_countN = 0;
}
}
/* Here the last line will contain "#0 BREAK" and thus does not need
* to be processed, but we do need to continue reading until we get
* an ESL prompt. */
while((int_charN = ComGetc(comN)) != ((int) '>'));
printf("\n");
close(handleN);
return(0);
}
/*
** Function: int pa_essample(COMPORT comN, int estypeN,
** int esoperationN, char *sampfileS,
** int samptimeN, unsigned int cyclesN);
**
** Description: This function controls an ES 1800 emulator to sample
** instruction fetch cycles from a target system. Note that
** any previous event monitor configuration is overwritten
** by the event monitor configuration required to support
** instruction fetch sampling.
**
** The comN handle selects the serial port that the ES 1800
** is connected to.
**
** "Basic" Emulator types currently supported:
** estypeN =
** PA_020S 68020 (supervisor program instr. fetch)
** PA_020U 68020 (user program instr. fetch)
** (The ES 1800 68020 emulator must be
** configured to use its "COMPUTER PORT"
** in order to use the faster "TUP"
** command to upload trace memory.)
** PA_000S 6800x/010/302 (sup. prog. instr. fetch)
** PA_000U 6800x/010/302 (user prog. instr. fetch)
** PA_80X86 80x86 (808x,8018x,80C18x,80286)
** PA_Z8K Z800x
**
** Emulator operations supported:
** esoperationN =
** PA_RST_RBV_STP Reset the target, load program counter
** from vector table, and start program
** execution. The target will be halted
** after the sample period.
** ("RST", "RBV", then "STP")
**
** PA_RBK_STP Run from current configuration. The
** target is assumed to initially be
** halted, and will be halted after the
** sampling period.
** ("RBK", then "STP")
**
** PA_RBK_RUN Run from current configuration. The
** target is assumed to be running.
** The "RBK" command enables the event
** monitor to trace cycles and a "RUN"
** disables the event monitor.
**
** sampfileS points to the string that gives the file to write
** the binary format instruction fetch address cycles to.
**
** samptimeN gives the number of seconds to sample instruction
** fetch cycles from the target system. If the ES 1800's trace
** buffer is overrun, then the trace buffer acts as a circular
** buffer that tracks the most recent 2045 instruction fetch
** samples.
**
** cyclesN gives the number of bus cycles to allow between
** instruction fetch samples. (0 to 65536)
**
*/
int
pa_essample(comN, estypeN, esoperationN, sampfileS, samptimeN, cyclesN)
COMPORT comN; /* Handle to comport to use */
int estypeN; /* Emulator type code */
int esoperationN; /* Emulator operation code */
char *sampfileS; /* Pntr to name of file to write samples to */
int samptimeN; /* Sampling duration in seconds */
unsigned int cyclesN; /* Number of buss cycles between samples */
{
time_t t; /* For recording run start time */
int errcodeN; /* Error code */
char stagebufAC[32]; /* Staging buffer for ESL commands */
/* Clear current event monitor configuration */
if ((errcodeN = pa_essend(comN, "CES\r")) != 0)
return(errcodeN);
/* Configure the event monitor system. This depends on the type of
* emulator being used. */
printf("Configuring the Event Monitor system\n");
switch(estypeN)
{
case PA_020S:
case PA_020U:
/* 68020 emulator, assume trace mode 2, 32 bit address, 32 bit data,
* limited status. In this case, AC1 and S1 are used as a 32 bit
* address comparator. S2 is used to limit traced bus cycles to
* supervisory program or user program. */
/* Send the event monitor configuration. */
if ((errcodeN = pa_essend(comN, "WHEN AC1 AND S1 THEN CNT\r")) != 0)
return(errcodeN);
if ((errcodeN = pa_essend(comN, "WHEN CL AND S2 THEN TRC,RCT\r")) != 0)
return(errcodeN);
/* Send the values of the address comparator registers. */
if ((errcodeN = pa_essend(comN, "AC1=0 TO $FFFFFF\r")) != 0)
return(errcodeN);
if ((errcodeN = pa_essend(comN, "S1=0 DC $FFFF\r")) != 0)
return(errcodeN);
/* Send the value of the number of buss cycles between traced cycles */
strcpy(stagebufAC, "CL=$");
sprintf(&(stagebufAC[4]), "%x\r", cyclesN);
if ((errcodeN = pa_essend(comN, stagebufAC)) != 0)
return(errcodeN);
/* Send the value of the buss cycle type to trace */
if (estypeN == PA_020S)
{
strcpy(stagebufAC, "S2=SP\r"); /* Trace supervisor program */
printf("Configured to trace 68020 Supervisor Program fetch cycles\n");
}
else
{
strcpy(stagebufAC, "S2=UP\r"); /* Trace user program */
printf("Configured to trace 68020 User Program fetch cycles\n");
}
if ((errcodeN = pa_essend(comN, stagebufAC)) != 0)
return(errcodeN);
break;
case PA_000S:
case PA_000U:
/* 68000 class emulator, assume 24 bit address, 8/16 bit data,
* full status. AC1 is used as an address comparator. S1 is used to
* limit traced bus cycles to supervisory program or user program. */
/* Send the event monitor configuration. */
if ((errcodeN = pa_essend(comN, "WHEN AC1 THEN CNT\r")) != 0)
return(errcodeN);
if ((errcodeN = pa_essend(comN, "WHEN CL AND S1 THEN TRC,RCT\r")) != 0)
return(errcodeN);
/* Send the values of the address comparator registers. */
if ((errcodeN = pa_essend(comN, "AC1=0 TO $FFFFFF\r")) != 0)
return(errcodeN);
/* Send the value of the number of buss cycles between traced cycles */
strcpy(stagebufAC, "CL=$");
sprintf(&(stagebufAC[4]), "%x\r", cyclesN);
if ((errcodeN = pa_essend(comN, stagebufAC)) != 0)
return(errcodeN);
/* Send the value of the buss cycle type to trace */
if (estypeN == PA_000S)
{
strcpy(stagebufAC, "S1=SP\r"); /* Trace supervisor program */
printf("Configured to trace 68000 Supervisor Program fetch cycles\n");
}
else
{
strcpy(stagebufAC, "S1=UP\r"); /* Trace user program */
printf("Configured to trace 68000 User Program fetch cycles\n");
}
if ((errcodeN = pa_essend(comN, stagebufAC)) != 0)
return(errcodeN);
break;
case PA_80X86:
/* 80x86 class emulator, assume 24 bit address, 8/16 bit data,
* full status. AC1 is used as an address comparator. S1 is used to
* limit traced bus cycles to instruction fetch. */
/* Send the event monitor configuration. */
if ((errcodeN = pa_essend(comN, "WHEN AC1 THEN CNT\r")) != 0)
return(errcodeN);
if ((errcodeN = pa_essend(comN, "WHEN CTL AND S1 THEN TRC,RCT\r")) != 0)
return(errcodeN);
/* Send the values of the address comparator registers. */
if ((errcodeN = pa_essend(comN, "AC1=0 TO $FFFFFF\r")) != 0)
return(errcodeN);
/* Send the value of the number of buss cycles between traced cycles */
printf("Configured to trace 80X86 instruction fetch cycles\n");
strcpy(stagebufAC, "CTL=$");
sprintf(&(stagebufAC[5]), "%x\r", cyclesN);
if ((errcodeN = pa_essend(comN, stagebufAC)) != 0)
return(errcodeN);
/* Send the value S1 to the trace only instruction fetch cycles */
if ((errcodeN = pa_essend(comN, "S1=IF\r")) != 0)
return(errcodeN);
break;
case PA_Z8K:
/* Z800x class emulator, assume 24 bit address, 8/16 bit data,
* full status. A1 is used as an address comparator. S1 is used to
* limit traced bus cycles to instruction fetch. */
/* Send the event monitor configuration. */
if ((errcodeN = pa_essend(comN, "WHEN A1 THEN CNT\r")) != 0)
return(errcodeN);
if ((errcodeN = pa_essend(comN, "WHEN CL AND S1 THEN TRC,RCT\r")) != 0)
return(errcodeN);
/* Send the values of the address comparator registers. */
if ((errcodeN = pa_essend(comN, "A1=0 TO $FFFFFF\r")) != 0)
return(errcodeN);
/* Send the value of the number of buss cycles between traced cycles */
printf("Configured to trace Z800X instruction fetch cycles\n");
strcpy(stagebufAC, "CL=$");
sprintf(&(stagebufAC[4]), "%x\r", cyclesN);
if ((errcodeN = pa_essend(comN, stagebufAC)) != 0)
return(errcodeN);
/* Send the value S1 to the trace only first instruction fetch
* cycles */
if ((errcodeN = pa_essend(comN, "S1=INS1\r")) != 0)
return(errcodeN);
break;
default:
/* Other types not currently supported */
return(PA_NOT_IMPL_E);
}
/* Start sampling. This depends on the initial state of the emulator. */
printf("Starting sampling\n");
/* Synchronize time to have consistant time intervals. */
t = time(NULL); /* Get initial starting time. */
while (time(NULL) == t); /* Wait for second transition */
switch(esoperationN)
{
case PA_RST_RBV_STP:
/* Reset the target, load program counter/stack pointer from
* the target system's reset vectors, and start the target program
* running. */
if ((errcodeN = pa_essend(comN, "RST\r")) != 0)
return(errcodeN);
if ((errcodeN = pa_essend(comN, "RBV\r")) != 0)
return(errcodeN);
printf("RST / RBV start up sequence\n");
break;
case PA_RBK_STP:
/* Run from the current configuration. The target system is assumed
* to be stopped, but is all set up to run. */
if ((errcodeN = pa_essend(comN, "RBK\r")) != 0)
return(errcodeN);
printf("RBK start up sequence\n");
break;
case PA_RBK_RUN:
/* Run from the current configuration. The target system is assumed
* to be running */
if ((errcodeN = pa_essend(comN, "OFF TCE\r")) != 0)
return(errcodeN);
if ((errcodeN = pa_essend(comN, "RBK\r")) != 0)
return(errcodeN);
if ((errcodeN = pa_essend(comN, "ON TCE\r")) != 0)
return(errcodeN);
printf("OFF TCE / RBK / ON TCE start up sequence\n");
break;
default:
/* Other modes not currently supported */
return(PA_NOT_IMPL_E);
}
/* Wait a bit for the target to run. */
t = time(NULL); /* Get new starting time. */
while ((time(NULL) - t) < samptimeN);
/* Stop sampling. This depends on the desired final state of the
* emulator. */
printf("Stopping sampling\n");
switch(esoperationN)
{
case PA_RST_RBV_STP:
case PA_RBK_STP:
/* Stop the target system. */
if ((errcodeN = pa_essend(comN, "STP\r")) != 0)
return(errcodeN);
printf("STP stop sequence\n");
break;
case PA_RBK_RUN:
/* Stop trace capture, keep the target system running. */
if ((errcodeN = pa_essend(comN, "OFF TCE\r")) != 0)
return(errcodeN);
if ((errcodeN = pa_essend(comN, "RUN\r")) != 0)
return(errcodeN);
printf("OFF TCE / RUN stop sequence\n");
break;
default:
/* Other modes not currently supported */
return(PA_NOT_IMPL_E);
}
/* Upload trace memory. How this is done depends on the type of
* emulator being used. */
printf("Uploading trace memory, please wait...\n");
switch(estypeN)
{
case PA_020S:
case PA_020U:
return(pa_estup(comN, sampfileS));
default:
return(pa_esdrt(comN, sampfileS));
}
}